package com.d2rv.offscreen;

import com.d2rv.guide.GoalManager;
import com.d2rv.model.CityModelManager;
import com.d2rv.skybox.SkyboxManager;
import com.d2rv.user.UserManager;
import processing.core.PApplet;

/**
 * This class is the manager of the offscreen user.
 *
 * @author Darrieutort A., Dupouy A., Rossignol L., Van Poucke A.
 */
public class OffScreenUserManager {

    private MonoModeManager monomodemanager;
    private StereoModeManager stereomodemanager;

    /**
     * Default constructor.
     *
     * @param parent the current application
     * @param usermanager the manager of the user
     * @param citymodelmanager the manager of the city model
     * @param skyboxmanager the manager of the skybox
     * @param goalmanager the manager of the goal
     */
    public OffScreenUserManager(PApplet parent, UserManager usermanager, CityModelManager citymodelmanager, SkyboxManager skyboxmanager, GoalManager goalmanager) {
        this.monomodemanager = new MonoModeManager(parent, usermanager, citymodelmanager, skyboxmanager, goalmanager);
        this.stereomodemanager = new StereoModeManager(parent, usermanager, citymodelmanager, skyboxmanager, goalmanager);
    }

    /**
     * Calls the draw method of the stereo mode manager
     *
     * @param mode different mode between stereo et mono
     */
    public void draw(int mode) {
        if (mode > 0) {
            this.stereomodemanager.draw(mode);
        } else {
            this.monomodemanager.draw();
        }
    }

    /**
     * Calls the show method of the stereo mode ande mono mode.
     *
     * @param parent the current application
     * @param mode different mode between stereo et mono
     */
    public void show(PApplet parent, int mode) {
        if (mode > 0) {
            this.stereomodemanager.show(parent, parent.width / 2, 0, mode);
        } else {
            this.monomodemanager.show(parent, parent.width / 2, 0);
        }
    }

    /**
     * Updates the light state of the scene
     *
     * @param state
     */
    public void light(boolean state) {
        this.monomodemanager.offscreenusermono().light(state);
        this.stereomodemanager.anaglyphemanager().offscreenuseranaglyphe().light(state);
        this.stereomodemanager.sidebysidemanager().offscreenusersidebysideleft().light(state);
        this.stereomodemanager.sidebysidemanager().offscreenusersidebysideright().light(state);
    }
}